﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Common;

namespace PassportManage
{
    public partial class Form_ManualEidtPassport : Form
    {
        public PassportInfoData p;
        public Form_ManualEidtPassport(PassportInfoData p)
        {
            InitializeComponent();
            this.p = p;
            this.Text = string.Format("手工编辑条码为{0}的护照信息",p.TaskCode);
//             numericUpDown1.Maximum = BLL.Properties.Settings.Default.PillarCount;
//             numericUpDown2.Maximum = BLL.Properties.Settings.Default.LayerCount;
//             numericUpDown3.Maximum = BLL.Properties.Settings.Default.CellCount;
        }

        private void Form_ManualEidtPassport_Shown(object sender, EventArgs e)
        {
            textBox1.Text = p.Name;
            dateTimePicker1.Value = p.Birthday;
            textBox2.Text = p.CardID;
            textBox3.Text = p.CardCode;
            textBox4.Text = p.OprationNumber;
            
            numericUpDown2.Value = p.Layer;
            numericUpDown3.Value = (int)((p.Cell - 1) / 10);
            numericUpDown1.Value = (int)((p.Cell - 1) % 10);
      
            textBox1.Enabled = false;
            dateTimePicker1.Enabled = false;
            textBox2.Enabled = false;
            textBox3.Enabled = false;
            textBox4.Enabled = false;
           
        }

        private void button1_Click(object sender, EventArgs e)
        {
            p.Name = textBox1.Text;
            p.Birthday = dateTimePicker1.Value;
            p.CardID = textBox2.Text;
            p.CardCode = textBox3.Text;
            p.OprationNumber = textBox4.Text;
            p.Pillar = 1;
            p.Layer = (int)numericUpDown2.Value;
            p.Cell = (int)(numericUpDown3.Value*10+numericUpDown1.Value);
            p.AddTime = DateTime.Now;
            p.Operator = AppInfo.Operator;
            BLL.PassportInfo bpi = new BLL.PassportInfo();
            if (bpi.EditPassport(p))
                DialogResult = DialogResult.OK;
            else
                DialogResult = DialogResult.Cancel;
        }
    }
}
